import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:short_video_app/network/base_entity.dart';
import 'package:short_video_app/network/http_manager.dart';
import 'package:short_video_app/utils/hud_util.dart';

class PublishViewModel extends ChangeNotifier {
  TextEditingController introduceController = TextEditingController();
  String _imageurl;

  PublishViewModel(this._imageurl);


  get imageurl => _imageurl;

  Future<void> publish(BuildContext context) async {
    debugPrint("publish-------");
    Map<String, dynamic> params = {};
    params["imgUrl"] = _imageurl;
    params["title"]= introduceController.text;
    params["videoUrl"] = _imageurl;
    debugPrint("----=====000${_imageurl}----==");
    var url = "/api/app/video/publish";
    IBaseEntity? result = await HttpManager.getInstance().request(url: url,params: params);

    if(kDebugMode){
      print(result?.getData());
      print(result?.isSuccess());
    }
    if(result?.isSuccess()==true){
      HudUtil.toast("发布成功");
    }

  }
}
